# 贝叶斯计算示例
def bayes_cancer_screening():
    # 先验概率
    P_cancer = 0.008      # 患病率0.8%
    P_healthy = 0.992     # 健康率99.2%
    
    # 似然度
    P_positive_if_cancer = 0.98    # 患癌时检测阳性概率
    P_positive_if_healthy = 0.03   # 健康时假阳性概率
    
    # 计算证据概率
    P_positive = (P_positive_if_cancer * P_cancer + 
                 P_positive_if_healthy * P_healthy)
    
    # 贝叶斯公式计算后验概率
    P_cancer_if_positive = (P_positive_if_cancer * P_cancer) / P_positive
    
    return P_cancer_if_positive

result = bayes_cancer_screening()
print(f"检测阳性时真实患癌概率: {result:.2%}")
